package org.t2.game.server;

import java.util.Collections;

import org.gaming.fakecmd.side.game.GameCmdManager;
import org.gaming.ruler.eventbus.EventBus;
import org.gaming.ruler.schedule.ScheduleManager;
import org.gaming.tool.ConsoleUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.t2.game.server.foundation.starting.ProjectBooter;

/**
 * @Auther YY
 */
@ComponentScan(basePackages = {"org.gaming", "org.t2", "sh.t2" })
@SpringBootApplication
public class T2GameServer {

    public static void main(String[] args) {

        SpringApplication springApplication = new SpringApplication();
        //服务器启动引导
        springApplication.addListeners(new ProjectBooter());

        springApplication.addPrimarySources(Collections.singletonList(T2GameServer.class));
        springApplication.run(args);

        ConsoleUtil.addFunction("stop", () -> { System.exit(0); });
        ConsoleUtil.addFunction("printConsoleFunction", ConsoleUtil::printFunction);
        ConsoleUtil.addFunction("printEventTrace", EventBus::printTrace);
        ConsoleUtil.addFunction("printCmd", GameCmdManager::printCmd);
        ConsoleUtil.addFunction("printSchedule", ScheduleManager::print);
        ConsoleUtil.inputListening();
    }
}
